<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  
  <meta name="generator" content="Hugo 0.98.0" />

  
  <meta name="description" content="走在通往幸福的路上">
  

  
  <link rel="apple-touch-icon" sizes="180x180" href="https://blog.v5u.win/apple-touch-icon.png">

  
  <link rel="icon" type="image/png" sizes="32x32" href="https://blog.v5u.win/favicon-32x32.png">

  
  <link rel="icon" type="image/png" sizes="16x16" href="https://blog.v5u.win/favicon-16x16.png">

  
  <link rel="manifest" href="https://blog.v5u.win/site.webmanifest">

  
  <link rel="mask-icon" href="https://blog.v5u.win/safari-pinned-tab.svg" color="">

  <meta name="msapplication-TileColor" content="">

  <meta name="theme-color" content="">

  
  <link rel="stylesheet" href="https://blog.v5u.win/css/bootstrap.min.css" />

  
  <title>mac虚拟机上的centos 7实现ssh连接 | 为吾优</title>
  

  <style>
body {
  min-width: 300px;
}

.custom-navbar {
  margin-bottom: 1em;
  height: 60px;
}

.custom-navbar a {
  display: inline-block; 
  padding: 18px 0;
  margin-right: 1em; 
  font-weight: bold; 
}

.custom-navbar a:hover,
.custom-navbar a:focus {
  text-decoration: none; 
}

@media print {
  .custom-navbar {
    display: none;
  }
}

article {
  padding-bottom: 1em;
}

img {
  max-width: 100%;
}


body {
  background-color: #fff;
}



body {
  color: #212529;
}



a {
  color: #007bff;
}



a:hover,
a:focus {
  color: #0056b3;
}



.custom-navbar {
  background-color: #212529;
}



.custom-navbar a {
  color: rgba(255,255,255,.75);
}



.custom-navbar a:hover,
.custom-navbar a:focus {
  color: rgba(255,255,255,1);
}



.container {
  max-width: 800px;
}





</style>
</head>

<body>
  <nav class="custom-navbar">
  <div class="container">
    
    <a href="/">文章</a>
    
    <a href="/tags/">标签</a>
    
    <a href="/about/">关于</a>
    
    <a href="/index.xml">RSS</a>
    
  </div>
</nav>
  
  <div class="container">
    <article>
      <h1>mac虚拟机上的centos 7实现ssh连接</h1>
<p>mac虚拟机上的centos7实现ssh连接</p>
<ol>
<li>
<p>查看是否安装ssh rpm -qa | grep ssh（一般都内置了）</p>
</li>
<li>
<p>配置sshd_config文件 /etc/ssh/sshd_config</p>
</li>
</ol>
<pre><code>Port 22
ListenAddress 0.0.0.0
ListenAddress ::
</code></pre>
<ol>
<li>防火墙配置</li>
</ol>
<pre><code>1. 安装iptables: yum install iptables-service
2. 配置防火墙文件：vim /etc/sysconfig/iptables
3. 关闭防火墙：systemctl restart iptables.service
4. systemctl enable iptables.service //设置防火墙开机启动
</code></pre>
<ol>
<li>安装netstat：yum install net-tools （查看监听端口：netstat -ntpl | grep 22）</li>
<li>关闭虚拟机，设置虚拟机网络为host-only方式，virtualbox需要设置全局设置</li>
</ol>
<pre><code>1. cmd+,-&gt;网络-&gt;仅主机(host-only)网络
2. 添加网络
</code></pre>
<ol>
<li>查看虚拟机ip地址，ip <code>ip addr</code></li>
<li>主机找到可以ping 通的ip</li>
<li>ssh登录 ssh <a href="mailto:root@192.168.xx.xx">root@192.168.xx.xx</a></li>
</ol>

    </article>
  </div>

  
  
  

  
</body>

</html>